Skip to content

drivers/rtc: fix rcu unexpected reboot#592

Open
yanmarkman wants to merge 1 commit into
sonic-net:202505from
yanmarkman:yanm-drivers-rtc-fix-rcu-unexp-reboot-202505
Open

drivers/rtc: fix rcu unexpected reboot#592
yanmarkman wants to merge 1 commit into
sonic-net:202505from
yanmarkman:yanm-drivers-rtc-fix-rcu-unexp-reboot-202505

Conversation

@yanmarkman

Copy link
Copy Markdown
Contributor

Why needed (PROBLEM):
Under 'chrony' configuration or/and further hwrtc change the RCU on the rtc_timer_do_work() reported and reproduced.

How fixed:
drivers/rtc/interface.c: rtc_timer_do_work()
When processing expired RTC events and rearming them, use "now"
instead of "expiry" to prevent endless loops.

Why needed (PROBLEM):
Under 'chrony' configuration or/and further hwrtc change
the RCU on the rtc_timer_do_work() reported and reproduced.

Easy reproduced on armhf Nokia-AC3X.
Not reproduced on SONiC TRIXIE.

How fixed:
drivers/rtc/interface.c: rtc_timer_do_work()
  When processing expired RTC events and rearming them, use "now"
  instead of "expiry" to prevent endless loops.

Signed-off-by: Elad Nachman <enachman@marvell.com>
Signed-off-by: Yan Markman <ymarkman@marvell.com>
@yanmarkman yanmarkman requested a review from a team as a code owner June 22, 2026 16:00
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@paulmenzel paulmenzel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also send this upstream for review.


When processing expired RTC events and rearming them, use now
instead of expiry to prevent endless loops.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a Fixes: tag, and also list the devices in the commit message.


+ if (rtc && rtc->ops && rtc->ops->read_time) {
+ if (!rtc->ops->read_time(rtc->dev.parent, &new_tm)) {
+ pr_err("new rtc tm %d %d %d %d %d %d %d %d %d\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please re-write. Currently it’s more like a debug message. (Which is good to have.)

/* Re-add/fwd periodic timers */
if (ktime_to_ns(timer->period)) {
- timer->node.expires = ktime_add(timer->node.expires,
+ timer->node.expires = ktime_add(now/*timer->node.expires*/,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have git, so commenting this out is not useful.

@yanmarkman

yanmarkman commented Jun 22, 2026 via email

Copy link
Copy Markdown
Contributor Author

yanmarkman added a commit to Marvell-switching/sonic-scripts that referenced this pull request Jun 23, 2026
@yanmarkman

Copy link
Copy Markdown
Contributor Author

HI @paulmenzel
@eladnachman has posted https://lkml.org/lkml/2026/6/24/888 to the Kernel-upstream

@saiarcot895

Copy link
Copy Markdown
Contributor

I'm inclined to agree with the comments on the mailing list. What is special about your hardware that common code needs to be changed here?

@eladnachman

Copy link
Copy Markdown
Contributor

I'm inclined to agree with the comments on the mailing list. What is special about your hardware that common code needs to be changed here?

The HW is not special, the test added that changes the clock back and forth constantly is special, and apparently no other SONIC HW uses RTC as the main clock.

@saiarcot895

Copy link
Copy Markdown
Contributor

apparently no other SONIC HW uses RTC as the main clock

No. I have done RTC time jumps back and forth on other hardware running SONiC. None of them leads to an expected reboot.

@eladnachman

Copy link
Copy Markdown
Contributor

apparently no other SONIC HW uses RTC as the main clock

No. I have done RTC time jumps back and forth on other hardware running SONiC. None of them leads to an expected reboot.

The question is whether those HW's RTC support PIE/UIE, whether it was enabled and rtc_timer_do_work() was actually called. Can you list these HW it was tested on, plus link to a HW diagram of the board and SOC, and finally a link to the dts or for x86_64 lspci -k ? Thanks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants